home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / obero / Interfaces3_4.lha / Interfaces / Utility.mod < prev    next >
Text File  |  1994-04-16  |  23KB  |  558 lines

  1. (*
  2. (*
  3. **  Amiga Oberon Interface Module:
  4. **  $VER: Utility.mod 40.15 (21.2.94) Oberon 3.4
  5. **
  6. **   © 1993 by Fridtjof Siebert
  7. **   updated for V39, V40 by hartmut Goebel
  8. *)
  9. *)
  10.  
  11. MODULE Utility;
  12.  
  13. (* !!! ATTENTION !!!
  14.  * Before you use any routine of this library, you'll have to check
  15.  * Utility.base # NIL.
  16.  *)
  17.  
  18. IMPORT e * := Exec,
  19.        SYSTEM;
  20.  
  21. CONST
  22.   utilityName * = "utility.library";
  23.  
  24. (*****************************************************************************)
  25. TYPE
  26.   ClockDataPtr * = UNTRACED POINTER TO ClockData;
  27.   HookPtr * = UNTRACED POINTER TO Hook;
  28.  
  29.   ClockData * = STRUCT
  30.     sec  * : INTEGER;
  31.     min  * : INTEGER;
  32.     hour * : INTEGER;
  33.     mday * : INTEGER;
  34.     month* : INTEGER;
  35.     year * : INTEGER;
  36.     wday * : INTEGER;
  37.   END;
  38.  
  39.  
  40. (* Useful definition for casting function pointers:
  41.  * hook.h_entry    = (ASMHOOKFUNC)AsmFunction
  42.  * hook.h_SubEntry = (HOOKFUNC)AFunction
  43.  *)
  44.   HookFunc * = PROCEDURE(hook: HookPtr; object: e.APTR; message: e.APTR): e.APTR;
  45.   AsmHookFunc * = PROCEDURE(hook{8}: HookPtr;
  46.                             object{10}: e.APTR;
  47.                             message{9}: e.APTR): e.APTR; (* assembler entry point *)
  48.  
  49.  
  50. (* new standard hook structure *)
  51.   Hook * = STRUCT (minNode * : e.MinNode)
  52.     entry    *: AsmHookFunc;  (* assembler entry point *)
  53.     subEntry *: HookFunc;     (* often HLL entry point *)
  54.     data     *: e.APTR;       (* owner specific        *)
  55.   END;
  56.  
  57. (* ---- Default Hook-Dispatcher ---- *)
  58. PROCEDURE HookEntry*(hook{8}: HookPtr;               (* $SaveRegs+ $StackChk- *)
  59.                      object{10}: e.APTR;
  60.                      message{9}: e.APTR): e.APTR;
  61. (*
  62.  * Calls haook.subEntry. The contents of A5 have to be stored in hook.data,
  63.  * else A5 would not be set correctly.
  64.  *)
  65.  
  66. BEGIN
  67.   SYSTEM.SETREG(13,hook.data);
  68.   RETURN hook.subEntry(hook,object,message);
  69. END HookEntry;
  70.  
  71.  
  72. PROCEDURE InitHook* (hook{8}: HookPtr; entry{9}: HookFunc);
  73. BEGIN
  74.   hook.entry := HookEntry;     (* $NilChk- -- one check is enough *)
  75.   hook.subEntry := entry;
  76.   hook.data := SYSTEM.REG(13); (* $NilChk= *)
  77. END InitHook;
  78.  
  79. (*
  80.  * Hook calling conventions:
  81.  *
  82.  * The function pointed to by Hook.h_Entry is called with the following
  83.  * parameters:
  84.  *
  85.  *    A0 - pointer to hook data structure itself
  86.  *    A1 - pointer to parameter structure ("message")
  87.  *    A2 - Hook specific address data ("object")
  88.  *
  89.  * Control will be passed to the routine h_Entry.  For many
  90.  * High-Level Languages (HLL), this will be an assembly language
  91.  * stub which pushes registers on the stack, does other setup,
  92.  * and then calls the function at h_SubEntry.
  93.  *
  94.  * The standard C receiving code is:
  95.  *
  96.  *    HookFunc(struct Hook *hook, APTR object, APTR message)
  97.  *
  98.  * Note that register natural order differs from this convention for C
  99.  * parameter order, which is A0,A2,A1.
  100.  *
  101.  * The assembly language stub for "vanilla" C parameter conventions
  102.  * could be:
  103.  *
  104.  * _hookEntry:
  105.  *    move.l  a1,-(sp)                ; push message packet pointer
  106.  *    move.l  a2,-(sp)                ; push object pointer
  107.  *    move.l  a0,-(sp)                ; push hook pointer
  108.  *    move.l  h_SubEntry(a0),a0       ; fetch C entry point ...
  109.  *    jsr     (a0)                    ; ... and call it
  110.  *    lea     12(sp),sp               ; fix stack
  111.  *    rts
  112.  *
  113.  * With this function as your interface stub, you can write a Hook setup
  114.  * function as:
  115.  *
  116.  * InitHook(struct Hook *hook, ULONG ( *c_function)(), APTR userdata)
  117.  * {
  118.  * ULONG ( *hookEntry)();
  119.  *
  120.  *     hook->h_Entry  = hookEntry;
  121.  *     hook->h_SubEntry = c_function;
  122.  *     hook->h_Data   = userdata;
  123.  * }
  124.  *
  125.  * With a compiler capable of registerized parameters, such as SAS C, you
  126.  * can put the C function in the h_Entry field directly. For example, for
  127.  * SAS C:
  128.  *
  129.  *   ULONG __saveds __asm HookFunc(register __a0 struct Hook *hook,
  130.  *                               register __a2 APTR         object,
  131.  *                               register __a1 APTR         message);
  132.  *
  133.  *)
  134.  
  135. (* ======================================================================= *)
  136. (* ==== TagItem ========================================================== *)
  137. (* ======================================================================= *)
  138. (* Tags are a general mechanism of extensible data arrays for parameter
  139.  * specification and property inquiry. In practice, tags are used in arrays,
  140.  * or chain of arrays.
  141.  *
  142.  *)
  143.  
  144. TYPE
  145.   Tag   * = e.APTR;
  146.   TagID * = LONGINT;
  147.  
  148.   TagItem * = STRUCT
  149.     tag  * : TagID; (* identifies the type of data *)
  150.     data * : Tag;   (* type-specific data          *)
  151.   END;
  152.  
  153.   TagItemPtr * = UNTRACED POINTER TO TagItem;
  154.   TagListPtr * = UNTRACED POINTER TO ARRAY MAX(INTEGER) OF TagItem;
  155.  
  156. (* Types for 'ARRAY OF TagItem'-Parameters: *)
  157.  
  158.   Tags1  * = ARRAY  1 OF TagItem;
  159.   Tags2  * = ARRAY  2 OF TagItem;
  160.   Tags3  * = ARRAY  3 OF TagItem;
  161.   Tags4  * = ARRAY  4 OF TagItem;
  162.   Tags5  * = ARRAY  5 OF TagItem;
  163.   Tags6  * = ARRAY  6 OF TagItem;
  164.   Tags7  * = ARRAY  7 OF TagItem;
  165.   Tags8  * = ARRAY  8 OF TagItem;
  166.   Tags9  * = ARRAY  9 OF TagItem;
  167.   Tags10 * = ARRAY 10 OF TagItem;
  168.   Tags11 * = ARRAY 11 OF TagItem;
  169.   Tags12 * = ARRAY 12 OF TagItem;
  170.   Tags13 * = ARRAY 13 OF TagItem;
  171.   Tags14 * = ARRAY 14 OF TagItem;
  172.   Tags15 * = ARRAY 15 OF TagItem;
  173.   Tags16 * = ARRAY 16 OF TagItem;
  174.   Tags17 * = ARRAY 17 OF TagItem;
  175.   Tags18 * = ARRAY 18 OF TagItem;
  176.   Tags19 * = ARRAY 19 OF TagItem;
  177.   Tags20 * = ARRAY 20 OF TagItem;
  178.   Tags21 * = ARRAY 21 OF TagItem;
  179.   Tags22 * = ARRAY 22 OF TagItem;
  180.   Tags23 * = ARRAY 23 OF TagItem;
  181.   Tags24 * = ARRAY 24 OF TagItem;
  182.   Tags25 * = ARRAY 25 OF TagItem;
  183.   Tags26 * = ARRAY 26 OF TagItem;
  184.   Tags27 * = ARRAY 27 OF TagItem;
  185.   Tags28 * = ARRAY 28 OF TagItem;
  186.   Tags29 * = ARRAY 29 OF TagItem;
  187.  
  188. CONST
  189. (*****************************************************************************)
  190.  
  191. (* constants for Tag.ti_Tag, control tag values *)
  192.   done   * = 0;    (* terminates array of TagItems. ti_Data unused *)
  193.   end    * = done; (* synonym for TAG_DONE                         *)
  194.   ignore * = 1;    (* ignore this item, not end of array           *)
  195.   more   * = 2;    (* ti_Data is pointer to another array of TagItems
  196.                     * note that this tag terminates the current array
  197.                     *)
  198.   skip   * = 3;    (* skip this and the next TagItem.data items    *)
  199.  
  200. (* differentiates user tags from system tags*)
  201.   user   * = 80000000H;
  202.  
  203. (* If the TAG_USER bit is set in a tag number, it tells utility.library that
  204.  * the tag is not a control tag (like TAG_DONE, TAG_IGNORE, TAG_MORE) and is
  205.  * instead an application tag. "USER" means a client of utility.library in
  206.  * general, including system code like Intuition or ASL, it has nothing to do
  207.  * with user code.
  208.  *)
  209.  
  210. (*****************************************************************************)
  211.  
  212. (* Tag filter logic specifiers for use with FilterTagItems() *)
  213.   filterAnd * = 0;     (* exclude everything but filter hits   *)
  214.   filterNot * = 1;     (* exclude only filter hits             *)
  215.  
  216. (*****************************************************************************)
  217.  
  218. (* Mapping types for use with MapTags() *)
  219.   removeNotFound * = 0;        (* remove tags that aren't in mapList *)
  220.   keepNotFound   * = 1;        (* keep tags that aren't in mapList   *)
  221.  
  222. TYPE
  223. (*****************************************************************************)
  224.  
  225. (* The named object structure
  226.  *)
  227.   NamedObjectPtr * = UNTRACED POINTER TO NamedObject;
  228.   NamedObject * = STRUCT
  229.     object * : e.APTR;     (* Your pointer, for whatever you want *)
  230.   END;
  231.  
  232. (* Tags for AllocNamedObject() *)
  233. CONST
  234.   nameSpace  * =   4000;    (* tag to define namespace      *)
  235.   userSpace  * =   4001;    (* tag to define userspace      *)
  236.   priority   * =   4002;    (* tag to define priority       *)
  237.   flags      * =   4003;    (* tag to define flags          *)
  238.  
  239. (* Flags for tag ANO_FLAGS *)
  240.   noDups    * =   0;       (* Default allow duplicates *)
  241.   case      * =   1;       (* Default to caseless... *)
  242.  
  243. (*****************************************************************************)
  244.  
  245.  
  246. (* PackTable definition:
  247.  *
  248.  * The PackTable is a simple array of LONGWORDS that are evaluated by
  249.  * PackStructureTags() and UnpackStructureTags().
  250.  *
  251.  * The table contains compressed information such as the tag offset from
  252.  * the base tag. The tag offset has a limited range so the base tag is
  253.  * defined in the first longword.
  254.  *
  255.  * After the first longword, the fields look as follows:
  256.  *
  257.  *      +--------- 1 = signed, 0 = unsigned (for bits, 1=inverted boolean)
  258.  *      |
  259.  *      |  +------ 00 = Pack/Unpack, 10 = Pack, 01 = Unpack, 11 = special
  260.  *      | / \
  261.  *      | | |  +-- 00 = Byte, 01 = Word, 10 = Long, 11 = Bit
  262.  *      | | | / \
  263.  *      | | | | | /----- For bit operations: 1 = TAG_EXISTS is TRUE
  264.  *      | | | | | |
  265.  *      | | | | | | /-------------------- Tag offset from base tag value
  266.  *      | | | | | | |                 \
  267.  *      m n n o o p q q q q q q q q q q r r r s s s s s s s s s s s s s
  268.  *                                      \   | |               |
  269.  *      Bit offset (for bit operations) ----/ |               |
  270.  *                                            \                       |
  271.  *      Offset into data structure -----------------------------------/
  272.  *
  273.  * A -1 longword signifies that the next longword will be a new base tag
  274.  *
  275.  * A 0 longword signifies that it is the end of the pack table.
  276.  *
  277.  * What this implies is that there are only 13-bits of address offset
  278.  * and 10 bits for tag offsets from the base tag.  For most uses this
  279.  * should be enough, but when this is not, either multiple pack tables
  280.  * or a pack table with extra base tags would be able to do the trick.
  281.  * The goal here was to make the tables small and yet flexible enough to
  282.  * handle most cases.
  283.  *)
  284.  
  285.   signed * = 31;
  286.   unpack * = 30;    (* Note that these are active low... *)
  287.   pack   * = 29;    (* Note that these are active low... *)
  288.   exists * = 26;    (* Tag exists bit true flag hack...  *)
  289.  
  290. (*****************************************************************************)
  291.  
  292.  
  293.   ctrlPackUnpack * = 000000000H;
  294.   ctrlPackOnly   * = 040000000H;
  295.   ctrlUnpackOnly * = 020000000H;
  296.  
  297.   ctrlByte       * = 080000000H;
  298.   ctrlWord       * = 088000000H;
  299.   ctrlLong       * = 090000000H;
  300.  
  301.   ctrlUByte      * = 000000000H;
  302.   ctrlUWord      * = 008000000H;
  303.   ctrlULong      * = 010000000H;
  304.  
  305.   ctrlBit        * = 018000000H;
  306.   ctrlFlipBit    * = 098000000H;
  307.  
  308. (*****************************************************************************)
  309.  
  310. TYPE
  311.   UtilityBasePtr * = UNTRACED POINTER TO UtilityBase;
  312.   UtilityBase * = STRUCT (libNode * : e.Library)
  313.     language   * : SHORTINT;
  314.     reserved   * : SHORTINT;
  315.   END;
  316.  
  317. (******************************************************************************)
  318.  
  319. (*
  320.  * Sorry, but since Oberon has no precompiler (this is good) and thuth
  321.  * no macros like in 'C', you this PACK macros can not be translated to
  322.  * Oberon :-(. If you got an idea, how to solve this problen (e.g. you
  323.  * have written a pre-compiler ;-) please contact us:
  324.  * e-mail: amok@oberon.nbg.sub.org
  325.  * snail-mail: see members of AMOK in the compiler manual
  326.  * THANKS!
  327.  *)
  328.  
  329. (* Macros used by the next batch of macros below. Normally, you don't use
  330.  * this batch directly. Then again, some folks are wierd
  331.  *)
  332. (*
  333. #define PK_BITNUM1(flg) ((flg) == 0x01 ? 0 : (flg) == 0x02 ? 1 : (flg) == 0x04 ? 2 : (flg) == 0x08 ? 3 : (flg) == 0x10 ? 4 : (flg) == 0x20 ? 5 : (flg) == 0x40 ? 6 : 7)
  334. #define PK_BITNUM2(flg) ((flg < 0x100 ? PK_BITNUM1(flg) : 8+PK_BITNUM1(flg >> 8)))
  335. #define PK_BITNUM(flg) ((flg < 0x10000 ? PK_BITNUM2(flg) : 16+PK_BITNUM2(flg >> 16)))
  336. #define PK_WORDOFFSET(flg) ((flg) < 0x100 ? 1 : 0)
  337. #define PK_LONGOFFSET(flg) ((flg) < 0x100  ? 3 : (flg) < 0x10000 ? 2 : (flg) < 0x1000000 ? 1 : 0)
  338. #define PK_CALCOFFSET(type,field) ((ULONG)(&((struct type * )0)->field))
  339. *)
  340.  
  341. (*****************************************************************************)
  342.  
  343.  
  344. (* Some handy dandy macros to easily create pack tables
  345.  *
  346.  * Use PACK_STARTTABLE() at the start of a pack table. You pass it the
  347.  * base tag value that will be handled in the following chunk of the pack
  348.  * table.
  349.  *
  350.  * PACK_ENDTABLE() is used to mark the end of a pack table.
  351.  *
  352.  * PACK_NEWOFFSET() lets you change the base tag value used for subsequent
  353.  * entries in the table
  354.  *
  355.  * PACK_ENTRY() lets you define an entry in the pack table. You pass it the
  356.  * base tag value, the tag of interest, the type of the structure to use,
  357.  * the field name in the structure to affect and control bits (combinations of
  358.  * the various PKCTRL_XXX bits)
  359.  *
  360.  * PACK_BYTEBIT() lets you define a bit-control entry in the pack table. You
  361.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  362.  * affects. This macro should be used when the field being affected is byte
  363.  * sized.
  364.  *
  365.  * PACK_WORDBIT() lets you define a bit-control entry in the pack table. You
  366.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  367.  * affects. This macro should be used when the field being affected is word
  368.  * sized.
  369.  *
  370.  * PACK_LONGBIT() lets you define a bit-control entry in the pack table. You
  371.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  372.  * affects. This macro should be used when the field being affected is longword
  373.  * sized.
  374.  *
  375.  * EXAMPLE:
  376.  *
  377.  *    ULONG packTable[] =
  378.  *    {
  379.  *         PACK_STARTTABLE(GA_Dummy),
  380.  *         PACK_ENTRY(GA_Dummy,GA_Left,Gadget,LeftEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  381.  *         PACK_ENTRY(GA_Dummy,GA_Top,Gadget,TopEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  382.  *         PACK_ENTRY(GA_Dummy,GA_Width,Gadget,Width,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  383.  *         PACK_ENTRY(GA_Dummy,GA_Height,Gadget,Height,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  384.  *         PACK_WORDBIT(GA_Dummy,GA_RelVerify,Gadget,Activation,PKCTRL_BIT|PKCTRL_PACKUNPACK,GACT_RELVERIFY)
  385.  *         PACK_ENDTABLE
  386.  *    };
  387.  *)
  388. (*
  389. #define PACK_STARTTABLE(tagbase)                           (tagbase)
  390. #define PACK_NEWOFFSET(tagbase)                            (-1L),(tagbase)
  391. #define PACK_ENDTABLE                                      0
  392. #define PACK_ENTRY(tagbase,tag,type,field,control)         (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field))
  393. #define PACK_BYTEBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field) | (PK_BITNUM(flags) << 13L))
  394. #define PACK_WORDBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | (PK_CALCOFFSET(type,field)+PK_WORDOFFSET(flags)) | ((PK_BITNUM(flags)&7) << 13L))
  395. #define PACK_LONGBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | (PK_CALCOFFSET(type,field)+PK_LONGOFFSET(flags)) | ((PK_BITNUM(flags)&7) << 13L))
  396.  *)
  397.  
  398. (*****************************************************************************)
  399.  
  400. VAR
  401.   base * : UtilityBasePtr;
  402.  
  403.  
  404. (* $OvflChk- $RangeChk- $StackChk- $NilChk- $ReturnChk- $CaseChk- *)
  405.  
  406.  
  407. (*--- functions in V36 or higher (Release 2.0) ---*)
  408.  
  409. (* Tag item functions *)
  410.  
  411. PROCEDURE FindTagItemA    *{base,- 30}(tagVar{0}      : TagID;
  412.                                        tagList{8}     : ARRAY OF TagItem): TagItemPtr;
  413. PROCEDURE FindTagItem     *{base,- 30}(tagVar{0}      : TagID;
  414.                                        tags{8}        : TagListPtr): TagItemPtr;
  415. PROCEDURE GetTagDataPA    *{base,- 36}(tagVal{0}      : TagID;
  416.                                        defaultValue{1}: e.APTR;
  417.                                        tagList{8}     : ARRAY OF TagItem): e.APTR;
  418. PROCEDURE GetTagDataA     *{base,- 36}(tagVal{0}      : TagID;
  419.                                        defaultValue{1}: LONGINT;
  420.                                        tagList{8}     : ARRAY OF TagItem): LONGINT;
  421. PROCEDURE GetTagDataP     *{base,- 36}(tagVal{0}      : TagID;
  422.                                        defaultValue{1}: e.APTR;
  423.                                        tags{8}        : TagListPtr): e.APTR;
  424. PROCEDURE GetTagData      *{base,- 36}(tagVal{0}      : TagID;
  425.                                        defaultValue{1}: LONGINT;
  426.                                        tags{8}        : TagListPtr): LONGINT;
  427. PROCEDURE PackBoolTagsA   *{base,- 42}(initialFlags{0}: LONGSET;
  428.                                        tagList{8}     : ARRAY OF TagItem;
  429.                                        boolMap{9}     : ARRAY OF TagItem): LONGSET;
  430. PROCEDURE PackBoolTags    *{base,- 42}(initialFlags{0}: LONGSET;
  431.                                        taga{8}        : TagListPtr;
  432.                                        boolMap{9}     : ARRAY OF TagItem): LONGSET;
  433. PROCEDURE NextTagItem     *{base,- 48}(VAR tagListPtr{8}: TagItemPtr): TagItemPtr;
  434. PROCEDURE FilterTagChanges*{base,- 54}(changeList{8}  : ARRAY OF TagItem;
  435.                                        originalList{9}: ARRAY OF TagItem;
  436.                                        apply{0}       : BOOLEAN);
  437. PROCEDURE MapTags         *{base,- 60}(tagList{8}     : ARRAY OF TagItem;
  438.                                        mapList{9}     : ARRAY OF TagItem;
  439.                                        mapType{0}     : LONGINT);
  440. PROCEDURE AllocateTagItems*{base,- 66}(numTags{0}     : LONGINT): TagListPtr;
  441. PROCEDURE CloneTagItemsA  *{base,- 72}(tagList{8}     : ARRAY OF TagItem): TagListPtr;
  442. PROCEDURE CloneTagItems   *{base,- 72}(taga{8}        : TagListPtr): TagListPtr;
  443. PROCEDURE FreeTagItems    *{base,- 78}(tagList{8}     : TagListPtr);
  444. PROCEDURE RefreshTagItemClones*{base,- 84}(clone{8}   : ARRAY OF TagItem;
  445.                                        original{9}    : ARRAY OF TagItem);
  446. PROCEDURE TagInArrayA     *{base,- 90}(tagValue{0}    : TagID;
  447.                                        tagArray{8}    : ARRAY OF TagItem): BOOLEAN;
  448. PROCEDURE TagInArray      *{base,- 90}(tagValue{0}    : TagID;
  449.                                        tags{8}        : TagListPtr): BOOLEAN;
  450. PROCEDURE FilterTagItems  *{base,- 96}(tagList{8}     : ARRAY OF TagItem;
  451.                                        filterArray{9} : ARRAY OF TagItem;
  452.                                        logic{0}       : LONGINT): LONGINT;
  453.  
  454. (* HOOK FUNCTIONS *)
  455.  
  456. PROCEDURE CallHookPkt     *{base,-102}(hook{8}        : HookPtr;
  457.                                        object{10}     : e.ADDRESS;
  458.                                        paramPacket{9} : e.ADDRESS): LONGINT;
  459.  
  460. (* DATE FUNCTIONS *)
  461.  
  462. PROCEDURE Amiga2Date      *{base,-120}(seconds{0}     : LONGINT;
  463.                                        VAR date{8}    : ClockData);
  464. PROCEDURE Date2Amiga      *{base,-126}(VAR date{8}    : ClockData): LONGINT;
  465. PROCEDURE CheckDate       *{base,-132}(VAR date{8}    : ClockData): LONGINT;
  466.  
  467. (* 32 bit integer muliply functions *)
  468.  
  469. PROCEDURE SMult32         *{base,-138}(factor1{0},  factor2{1} : LONGINT): LONGINT;
  470. PROCEDURE UMult32         *{base,-144}(factor1{0},  factor2{1} : LONGINT): LONGINT;
  471.  
  472. (* 32 bit integer division funtions. The quotient and the remainder are *)
  473. (* returned respectively in d0 and d1 *)
  474.  
  475. PROCEDURE SDivMod32       *{base,-150}(dividend{0}, divisor{1} : LONGINT): LONGINT;
  476. PROCEDURE UDivMod32       *{base,-156}(dividend{0}, divisor{1} : LONGINT): LONGINT;
  477.  
  478. (*--- functions in V37 or higher (Release 2.04) ---*)
  479.  
  480. (* International string routines *)
  481.  
  482. PROCEDURE Stricmp         *{base,-162}(string1{8}: ARRAY OF CHAR;
  483.                                        string2{9}: ARRAY OF CHAR): LONGINT;
  484. PROCEDURE Strnicmp        *{base,-168}(string1{8}: ARRAY OF CHAR;
  485.                                        string2{9}: ARRAY OF CHAR;
  486.                                        length{0}: LONGINT): LONGINT;
  487. PROCEDURE ToUpper         *{base,-174}(character{0}: CHAR): CHAR;
  488. PROCEDURE ToLower         *{base,-180}(character{0}: CHAR): CHAR;
  489.  
  490. (*--- functions in V39 or higher (Release 3) ---*)
  491.  
  492. (* More tag Item functions *)
  493.  
  494. PROCEDURE ApplyTagChangesA*{base,-0BAH}(list{8}          : ARRAY OF TagItem;
  495.                                         changeList{9}    : ARRAY OF TagItem);
  496. PROCEDURE ApplyTagChanges *{base,-0BAH}(list{8}          : ARRAY OF TagItem;
  497.                                         changeList{9}    : TagListPtr);
  498.  
  499. (* 64 bit integer muliply functions. The results are 64 bit quantities *)
  500. (* returned in D0 and D1 *)
  501.  
  502. PROCEDURE SMult64         *{base,-0C6H}(arg1{0}: LONGINT; arg2{1}: LONGINT): LONGINT;
  503. PROCEDURE UMult64         *{base,-0CCH}(arg1{0}: LONGINT; arg2{1}: LONGINT): LONGINT;
  504.  
  505. (* Structure to Tag and Tag to Structure support routines *)
  506.  
  507. PROCEDURE PackStructureTagsA  *{base,-0D2H}(pack{8}      : e.APTR;
  508.                                             packTable{9} : ARRAY OF LONGINT;
  509.                                             tagList{10}  : ARRAY OF TagItem): LONGINT;
  510. PROCEDURE PackStructureTags   *{base,-0D2H}(pack{8}      : e.APTR;
  511.                                             packTable{9} : ARRAY OF LONGINT;
  512.                                             tagList{10}  : TagListPtr): LONGINT;
  513. PROCEDURE UnpackStructureTagsA*{base,-0D8H}(pack{8}      : Tag;
  514.                                             packTable{9} : ARRAY OF LONGINT;
  515.                                             tagList{10}  : ARRAY OF TagItem): LONGINT;
  516. PROCEDURE UnpackStructureTags *{base,-0D8H}(pack{8}      : e.APTR;
  517.                                             packTable{9} : ARRAY OF LONGINT;
  518.                                             tagList{10}  : TagListPtr): LONGINT;
  519.  
  520. (* New, object-oriented NameSpaces *)
  521.  
  522. PROCEDURE AddNamedObject  *{base,-0DEH}(nameSpace{8}   : NamedObjectPtr;
  523.                                         object{9}      : NamedObjectPtr): BOOLEAN;
  524. PROCEDURE AllocNamedObjectA *{base,-0E4H}(name{8}      : ARRAY OF CHAR;
  525.                                           tagList{9}   : ARRAY OF TagItem): NamedObjectPtr;
  526. PROCEDURE AllocNamedObject  *{base,-0E4H}(name{8}      : ARRAY OF CHAR;
  527.                                           tag1{9}..    : Tag): NamedObjectPtr;
  528. PROCEDURE AttemptRemNamedObject*{base,-0EAH}( object{8}: NamedObjectPtr): BOOLEAN;
  529. PROCEDURE FindNamedObject  *{base,-0F0H}(nameSpace{8}  : NamedObjectPtr;
  530.                                          name{9}       : ARRAY OF CHAR;
  531.                                          lastObject{10}: NamedObjectPtr): NamedObjectPtr;
  532. PROCEDURE FreeNamedObject *{base,-0F6H}(object{8}      : NamedObjectPtr);
  533. PROCEDURE NamedObjectName *{base,-0FCH}(object{8}      : NamedObjectPtr): e.LSTRPTR;
  534. PROCEDURE ReleaseNamedObject*{base,-102H}(object{8}    : NamedObjectPtr);
  535. PROCEDURE RemNamedObject  *{base,-108H}(object{8}      : NamedObjectPtr;
  536.                                         message{9}     : e.MessagePtr);
  537.  
  538. (* Unique ID generator *)
  539.  
  540. PROCEDURE GetUniqueID     *{base,-10EH}(): LONGINT;
  541.  
  542.  
  543. (*---- usefull procedures ---- *)
  544.  
  545. PROCEDURE IgnoreIfNIL * (tagVal{0}: TagID; data{8}: Tag): TagID;
  546. BEGIN
  547.   IF data # NIL THEN RETURN tagVal ELSE RETURN ignore END;
  548. END IgnoreIfNIL;
  549.  
  550.  
  551. BEGIN
  552.   base :=  e.OpenLibrary(utilityName,37);
  553. CLOSE
  554.   IF base#NIL THEN e.CloseLibrary(base) END;
  555.  
  556. END Utility.
  557.  
  558.